package com.library.view.components;


import io.yukk1o.easytermui.base.BasePanel;
import io.yukk1o.easytermui.component.Button;

import java.util.List;

public class ButtonPanel extends BasePanel {

    public ButtonPanel(int relX, int relY, List<Button> buttonList, int separation) {
        super(relX, relY, countButtonWidth(buttonList, separation), 1);
        int posX = 0;
        for (Button button : buttonList) {
            button.setRelY(0);
            button.setRelX(posX);
            addComponent(button);

            posX += button.getWidth() + separation;

            button.setBindData(bindData);
        }
    }

    private static int countButtonWidth(List<Button> buttonList, int separation) {
        int width = buttonList.size() * separation;

        for (Button button : buttonList) {
            width += button.getWidth();
        }

        return width;
    }
}
